package com.example.utils.image;
import com.example.utils.Config;
import com.example.utils.DateUtils;
import com.example.utils.MyLog;
import com.example.utils.StringUtils;
import com.example.utils.json.DemonSkill;
import com.example.utils.json.Equipment;
import com.example.utils.json.Skill;
import org.apache.ibatis.io.Resources;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.ArrayList;

import javax.imageio.ImageIO;

public class DrawArmsUtils {

    // 星星距离
    private final static int starMarginLeft = 630;
    private final static int starMarginTop = 100;
    // 编号位置
    private final static int idMarginLeft = 130;
    private final static int idMarginTop = 128;

    // 图片位置
    private final static int imgMarginLeft = 200;
    private final static int imgMarginTop = 250;

    // 类型位置
    private final static int baseTypeMarginLeft = 610;
    private final static int baseTypeMarginTop = 180;

    // 负重位置
    private final static int costMarginLeft = 856;
    private final static int costMarginTop = 180;

    // 等级位置
    private final static int levelMarginLeft = 649;
    private final static int levelMarginTop = 211;

    // 请密度
    private final static int closeMarginLeft = 880;
    private final static int closeMarginTop = 215;

    // 标题位置
    private final static int titleMarginLeft = 315;
    private final static int titleMarginTop = 127;

    // 描述位置
    private final static int descMarginLeft = 150;
    private final static int descMarginTop = 450;

    // 技能1位置
    private final static int skillFirstMarginTop = 335;
    private final static int skillFirstMarginLeft = 595;
    private final static int skillFirstDescMarginTop = 362;

    // 伤害类型位置
    private final static int damageTypeMarginTop = 100;
    private final static int damageTypeMarginLeft = 590;

    //面板信息位置
    private final static int panelMarginTop = 255;
    private final static int panelMarginLeft = 610;

    // 破度
    private final static int brokenMarginTop = 315;
    private final static int brokenMarginLeft = 780;

    // 技能下划线
    private final static int killLineMarginTop = 343;
    private final static int killLineMarginLeft = 580;

    // 技能的伤害类型位置
    private final static int skillDamageTypeMarginTop = 310;
    private final static int skillDamageTypeMarginLeft = 936;

    // 系列位置
    private final static int seriesMarginTop = 100;
    private final static int seriesMarginLeft = 275;

    private final static String font1 = "微软雅黑";
    private final static String font2 = "";

    // 编号字体
    private final static Font ID_FONT = new Font(font1,Font.BOLD,26);
    // 编号颜色
    private final static Color ID_COLOR = new Color(255,255,255);

    // 名称字体
    private final static  Font TITLE_FONT = new Font(font1,Font.BOLD,24);
    // 名称颜色
    private final static Color TITLE_COLOR = new Color(114, 114, 114);

    // 类型字体
    private final static Font BASE_TYPE_FONT = new Font(font1,Font.BOLD,21);
    // 类型颜色
    private final static Color BASE_TYPE_COLOR = new Color(247, 145, 0);

    // 面板字体
    private final static Font PANEL_FONT = new Font(font1,Font.BOLD,20);
    // 面板颜色
    private final static Color PANEL_COLOR = new Color(114, 114, 114);

    // 技能名称字体
    private final static Font KILL_NAME_FONT = new Font(font1,Font.BOLD,24);
    // 技能名称颜色
    private final static Color KILL_NAME_COLOR = new Color(251, 153, 0);

    // 技能说明字体
    private final static Font KILL_CONTENT_FONT = new Font(font1,Font.BOLD,16);
    // 技能说明颜色
    private final static Color KILL_CONTENT_COLOR = new Color(114, 114, 114);
    private final static Color KILL_CONTENT_COLOR2 = new Color(10, 1, 114);

    //描述字体
    private final static Font DESC_FONT = new Font("微软雅黑",Font.BOLD,24);
    private final static Font DESC_FONT2 = new Font("微软雅黑",Font.BOLD,16);
    //描述颜色
    private final static Color DESC_NAME_COLOR = new Color(251, 153, 0);

        public static void main(String[] args) throws IOException {
            Equipment equipment = new Equipment();
            equipment.setRarity(10);
            equipment.setDamageMaxLv(1234);
            equipment.setFireRateMaxLv(14.5);
            equipment.setAmmoMaxLv(25);
            equipment.setBaseType("手枪-武器");
            equipment.setTitle("传说魔犬·磷火恶咒·闇");
            equipment.setCost(8);
            equipment.setMaxlv(99);
            equipment.setId(3500);
            equipment.setType(1);
            equipment.setDesc("唯一装备，携带时，其它来源的生命和弹药回复失效");

            Skill skill = new Skill();
            skill.setTitle("你们能不能");
            skill.setDesc("『白花』蓄力攻击后，增加80(110)%物理伤害，持续5秒；『黑渊』蓄力攻击后，增加80(110)%元素伤害，持续5秒");
            skill.setMaxLvDesc("『白花』蓄力攻击后，增加80(110)%物理伤害，持续5秒；『黑渊』蓄力攻击后，增加80(110)%元素伤害，持续5秒");

            Skill skill2 = new Skill();
            skill2.setTitle("像我一样成熟点");
            skill2.setDesc("快乐领域内，提升50%攻速，每秒回复5%全弹药");
            skill2.setMaxLvDesc("快乐领域内，提升50%攻速，每秒回复5%全弹药");

            DemonSkill demonSkill = new DemonSkill();
            demonSkill.setTitle("自宅结界");
            demonSkill.setType("奥义");
            demonSkill.setDesc("#!ALB(37)提升60(+6每破)%全伤害，持续10秒；标记场上所有敌人进行斩击，造成奥义期间敌人所承受所有伤害的50(+5每破)%的伤害");
            demonSkill.setMaxLvDesc("#!ALB(37)提升60(+6每破)%全伤害，持续10秒；标记场上所有敌人进行斩击，造成奥义期间敌人所承受所有伤害的50(+5每破)%的伤害");

            DemonSkill demonSkill2 = new DemonSkill();
            demonSkill2.setTitle("自宅结界");
            demonSkill2.setType("奥义");
            demonSkill2.setDesc("#!ALB(37)提升60(+6每破)%全伤害，持续10秒；标记场上所有敌人进行斩击，造成奥义期间敌人所承受所有伤害的50(+5每破)%的伤害");
            demonSkill2.setMaxLvDesc("#!ALB(37)提升60(+6每破)%全伤害，持续10秒；标记场上所有敌人进行斩击，造成奥义期间敌人所承受所有伤害的50(+5每破)%的伤害");

            DemonSkill demonSkill3 = new DemonSkill();
            demonSkill3.setTitle("自宅结界");
            demonSkill3.setType("奥义");
            demonSkill3.setDesc("#!ALB(37)提升60(+6每破)%全伤害，持续10秒；标记场上所有敌人进行斩击，造成奥义期间敌人所承受所有伤害的50(+5每破)%的伤害");
            demonSkill3.setMaxLvDesc("#!ALB(37)提升60(+6每破)%全伤害，持续10秒；标记场上所有敌人进行斩击，造成奥义期间敌人所承受所有伤害的50(+5每破)%的伤害");

            DemonSkill demonSkill4 = new DemonSkill();
            demonSkill4.setTitle("自宅结界");
            demonSkill4.setType("奥义");
            demonSkill4.setDesc("#!ALB(37)提升60(+6每破)%全伤害，持续10秒；标记场上所有敌人进行斩击，造成奥义期间敌人所承受所有伤害的50(+5每破)%的伤害");
            demonSkill4.setMaxLvDesc("#!ALB(37)提升60(+6每破)%全伤害，持续10秒；标记场上所有敌人进行斩击，造成奥义期间敌人所承受所有伤害的50(+5每破)%的伤害");

            java.util.List<Skill> skillList = new ArrayList<Skill>();
            java.util.List<DemonSkill> demonSkillList = new ArrayList<DemonSkill>();

            skillList.add(skill);
            skillList.add(skill2);

            demonSkillList.add(demonSkill);
            demonSkillList.add(demonSkill2);
            demonSkillList.add(demonSkill3);
            demonSkillList.add(demonSkill4);

            equipment.setSkills(skillList);
            equipment.setDemonSkills(demonSkillList);
            int height = 574;
            if(equipment.getType() == 4){
                height = 899;
            }
            BufferedImage bi = new BufferedImage(1024, height, BufferedImage.TYPE_INT_BGR);

            final File file = new File("D:\\javaPic.png");

            try {
                if(file.exists()) {
                    file.delete();
                    file.createNewFile();
                }
            }catch(IOException e) {
                e.printStackTrace();
            }

            File file1 = new File("D:3411.png");
            Image image = ImageIO.read(file1);
            Image bkImg = null;
            if(equipment.getType() == 4){
                bkImg = getResourceImage("bk4.png");
            }else{
                bkImg = getResourceImage("bk.png");
            }
            Image starImg = getResourceImage("star.png");
            Image broken = getResourceImage("broken.png");
            // 技能下划线
            Image line = getResourceImage("line.png");
            File file2 = new File("D:series.png");
            Image seriesImage = ImageIO.read(file2);
            File file3 = new File("D:damage.png");
            Image damageImage = ImageIO.read(file3);
            File file4 = new File("D:1075.png");
            Image animation = ImageIO.read(file4);
            BufferedImage dlurPicture = ImageUtils.getDlurPicture(bi);
            BufferedImage sharperPicture = ImageUtils.getSharperPicture(dlurPicture);
            writeImage(sharperPicture, "png", file,image,seriesImage,damageImage,bkImg,starImg,broken,line,animation,equipment,"full",0);
            System.out.println("绘图成功");

        }


     public static String getImage(Equipment equipment){
            final String gifFileName = equipment.getId()+"_all.gif";
            // 合成图片路径
            String CompositeGraphPath = RedisUtil.getString("coolq:CompositeGraphPath:" + gifFileName);
            if(StringUtils.isNotEmpty(CompositeGraphPath)){
                return CompositeGraphPath;
            }

             final String gifFilePath = "D:/Application/CQP_TULING/data/image/CompositeGraphPath/"+gifFileName;
             final String fileName = equipment.getId()+"_.png";
             final String fullFileName = equipment.getId()+"_full_.png";
             //final String fileName45 = equipment.getId()+"_45.png";
             //final String fullFileName45 = equipment.getId()+"_full_45.png";

            try{
                int height = 574;
                if(equipment.getType() == 4){
                    height = 899;
                }
                BufferedImage bi = new BufferedImage(1024, height, BufferedImage.TYPE_INT_BGR);
                final File file = new File("D:/Application/CQP_TULING/data/image/CompositeGraphPath/"+fileName);
                if(file.exists()) {file.delete(); file.createNewFile();}
                final File file2 = new File("D:/Application/CQP_TULING/data/image/CompositeGraphPath/"+fullFileName);
                if(file2.exists()) {file2.delete();file2.createNewFile();}

                // 装备图片
                String icon_path = "";
                String icon_temp = RedisUtil.getString("coolq:EquipmentIcon:" + equipment.getId());
                if(StringUtils.isNotEmpty(icon_temp)){
                    icon_path = icon_temp;
                }else {
                    icon_path = handlerIconImage(equipment);
                }
                File icon = new File(icon_path);
                Image image = ImageIO.read(icon);
                // 立绘图片
                Image animation = ImageUtils.getAnimationPic(equipment.getId());

                // 系列的图片
                Image seriesImage = null;
                if(equipment.getSeriesId()>0){
                    String series_path = "";
                    String series_temp = RedisUtil.getString("coolq:series:" + equipment.getSeriesId());
                    if(StringUtils.isNotEmpty(series_temp)){
                        series_path = series_temp;
                    }else {
                        series_path = handlerSeriesImage(equipment);
                    }
                    File seriesFile = new File(series_path);
                    seriesImage = ImageIO.read(seriesFile);
                }


                // 伤害类型的图片
                Image damageImage = null;
                if(StringUtils.isNotEmpty(equipment.getDamageType())){
                    String damage_path = "";
                    String damage_temp = RedisUtil.getString("coolq:damage:" + equipment.getDamageType());
                    if(StringUtils.isNotEmpty(damage_temp)){
                        damage_path = damage_temp;
                    }else {
                        damage_path = handlerDamageImage(equipment);
                    }

                    File damageFile = new File(damage_path);
                    damageImage = ImageIO.read(damageFile);
                }




                Image bkImg = null;
                if(equipment.getType() == 4){
                    bkImg = getResourceImage("bk4.png");
                }else{
                    bkImg = getResourceImage("bk.png");
                }
                Image starImg = getResourceImage("star.png");
                Image broken = getResourceImage("broken.png");
                // 技能下划线
                Image line = getResourceImage("line.png");

                writeImage(bi, "png", file,image,seriesImage,damageImage,bkImg,starImg,broken,line,animation,equipment,ImageKillType.ZERO,0);
                writeImage(bi, "png", file2,image,seriesImage,damageImage,bkImg,starImg,broken,line,animation,equipment,ImageKillType.FULL,0);


                // 合成gif图
                BufferedImage src1 = ImageIO.read(file);
                BufferedImage src2 = ImageIO.read(file2);
                AnimatedGifEncoder e = new AnimatedGifEncoder();
                e.setRepeat(0);
                e.start(gifFilePath);
                e.setQuality(5);
                e.setDelay(3000); // 1 frame per sec
                e.addFrame(src1);
                e.addFrame(src2);
                e.finish();

            }catch (Exception e){
                e.printStackTrace();
            }



            String filePath = "/CompositeGraphPath/"+gifFileName;
            RedisUtil.setString("coolq:CompositeGraphPath:" + gifFileName,filePath);

            return filePath;
     }

     private static String handlerIconImage(Equipment e){
         final String url = "https://static.image.mihoyo.com/hsod2_webview/images/broadcast_top/equip_icon/png/"+StringUtils.getThreeLen(e.getImg())+".png";
         String[] split = url.split("\\/");
         String fileName = split[split.length - 1];
         String filePath = "D:/Application/CQP_TULING/data/image/EquipmentIcon/" + fileName;
         File file = new File("D:/Application/CQP_TULING/data/image/EquipmentIcon/", fileName);
         InputStream inputStream = HttpUtils.getInputStreamByGet(url);
         HttpUtils.saveData(inputStream, file);
         RedisUtil.setString("coolq:EquipmentIcon:" + e.getId(),filePath);
         return filePath;
     }

     /**伤害类型
     *
     * @param e
     * @return
     */
     private static String handlerDamageImage(Equipment e){
         final String url = "https://redbean.tech/images/icons/Type/"+e.getDamageType()+".png";
         String[] split = url.split("\\/");
         String fileName = split[split.length - 1];
         String filePath = "D:/Application/CQP_TULING/data/image/damage/" + fileName;
         File file = new File("D:/Application/CQP_TULING/data/image/damage/", fileName);
         InputStream inputStream = HttpUtils.getInputStreamByGet(url);
         HttpUtils.saveData(inputStream, file);
         RedisUtil.setString("coolq:damage:" + e.getDamageType(),filePath);
         return filePath;
     }


    /**装备系列
     *
     * @param e
     * @return
     */
    private static String handlerSeriesImage(Equipment e){
        final String url = "https://redbean.tech/images/icons/SeriesNo/"+e.getSeriesId()+".png";
        String[] split = url.split("\\/");
        String fileName = split[split.length - 1];
        String filePath = "D:/Application/CQP_TULING/data/image/series/" + fileName;
        File file = new File("D:/Application/CQP_TULING/data/image/series/", fileName);
        InputStream inputStream = HttpUtils.getInputStreamByGet(url);
        HttpUtils.saveData(inputStream, file);
        RedisUtil.setString("coolq:series:" + e.getSeriesId(),filePath);
        return filePath;
    }

    /**
     * 读取json文件，返回json串
     * @param fileName
     * @return
     */
    private static Image getResourceImage(String fileName) {
        try {
            InputStream inputStream = null;
            try {
                inputStream = Resources.getResourceAsStream(fileName);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ImageIO.read(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }

    /** 通过指定参数写一个图片  */
    //type full 满破 null 普通
    private static boolean writeImage(
            BufferedImage bi,
            String picType,
            File file,
            Image image,
            Image seriesImage,
            Image damageImage,
            Image bk,
            Image star,
            Image broken,
            Image line,
            Image animation,
            Equipment equipment,
            String type,
            int route) {
        Graphics2D g = bi.createGraphics();

        if(route > 0){
            //g.rotate(Math.toRadians(route),bi.getWidth()/2,bi.getHeight()/2);
        }
        //消除文字锯齿
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

        // 绘制背景图
        g.drawImage(bk,0,0,null);
        // 绘制觉醒立绘
        if(type != null && type.equals("full")&&animation != null){
            g.drawImage(animation,-200,50,null);
        }else{
            // 绘制武器图片
            g.drawImage(image,imgMarginLeft,imgMarginTop,null);
        }

        if(seriesImage != null){
            // 绘制系列图片
            g.drawImage(seriesImage,seriesMarginLeft,seriesMarginTop,35,35,null);
        }
        if(damageImage != null){
            // 绘制伤害类型图片
            g.drawImage(damageImage,damageTypeMarginLeft,damageTypeMarginTop,30,30,null);
        }
        //消除画图锯
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        // 绘制编号
        g.setColor(ID_COLOR);
        g.setFont(ID_FONT);
        g.drawString("编号"+equipment.getId(),idMarginLeft,idMarginTop);

        // 绘制星级
        for (int i = 0; i < equipment.getRarity(); i++) {
          g.drawImage(star,starMarginLeft+(i*32),starMarginTop,null);
        }

        g.setFont(TITLE_FONT);
        g.setColor(TITLE_COLOR);
        // 绘制名称
        g.drawString(equipment.getTitle(),titleMarginLeft,titleMarginTop);

        g.setFont(PANEL_FONT);
        g.setColor(PANEL_COLOR);
        // 绘制负重
        if(equipment.getCost() >0){
            g.drawString(equipment.getCost()+"",costMarginLeft,costMarginTop);
        }
        // 绘制等级
        g.drawString(equipment.getMaxlv()+"/"+equipment.getMaxlv(),levelMarginLeft,levelMarginTop);
        String close = "0/50";
        if(animation != null){
            close = "0/99";
        }
        // 绘制亲密度
        g.drawString("0/50",closeMarginLeft,closeMarginTop);

        g.setColor(BASE_TYPE_COLOR);
        g.setFont(BASE_TYPE_FONT);

        // 绘制类型
        if(StringUtils.isNotEmpty(equipment.getBaseType())){
            g.drawString(equipment.getBaseType(),baseTypeMarginLeft,baseTypeMarginTop);
        }

        // 绘制描述
        if(StringUtils.isNotEmpty(equipment.getDesc())){
            g.setColor(DESC_NAME_COLOR);
            int add = 0;
            if(equipment.getDesc().getBytes().length > 57){
                g.setFont(DESC_FONT2);
                add = equipment.getDesc().getBytes().length;
            }else {
                add = equipment.getDesc().getBytes().length;
                g.setFont(DESC_FONT);
            }
            g.drawString(equipment.getDesc(),descMarginLeft-add,descMarginTop);
        }


        // 绘制武器/衣服/徽章技能
        if(equipment.getType() == 1 || equipment.getType() == 2||equipment.getType() == 3){
            g.setColor(PANEL_COLOR);
            g.setFont(PANEL_FONT);
            // 绘制武器面板
            if(equipment.getType() ==1){
                int left = 0,top=0;
                int tempLeft=200,tempTop=33;
                // 攻击力
                if(equipment.getDamageMaxLv()>0){
                   g.drawString("攻击力 "+equipment.getDamageMaxLv(),panelMarginLeft+(left*tempLeft),panelMarginTop+(top*tempTop));
                   left+=1;
                }
                // 射速
                if(equipment.getFireRateMaxLv()>0){
                    g.drawString("射 速 "+equipment.getFireRateMaxLv(),panelMarginLeft+(left*tempLeft),panelMarginTop+(top*tempTop));
                    top+=1;
                    left-=1;
                }
                // 载弹量
                if(equipment.getAmmoMaxLv()>0){
                    g.drawString("载弹 "+equipment.getAmmoMaxLv(),panelMarginLeft+(left*tempLeft),panelMarginTop+(top*tempTop));
                }
            // 绘制衣服面板
            }else if(equipment.getType() ==2){
                int left = 0,top=0;
                int tempLeft=200,tempTop=33;
                // 绘制血量
                if(equipment.getHpMaxLv() >0){
                    g.drawString("生命值 "+equipment.getHpMaxLv(),panelMarginLeft+(left*tempLeft),panelMarginTop+(top*tempTop));
                }
            }
            for (int i = 0; i < equipment.getSkills().size(); i++) {
                Skill skill = equipment.getSkills().get(i);
                g.setColor(KILL_NAME_COLOR);
                g.setFont(KILL_NAME_FONT);
                // 绘制技能名称
                g.drawString(skill.getTitle(),skillFirstMarginLeft,skillFirstMarginTop+(i*125));
                // 绘制技能下划线
                g.drawImage(line,killLineMarginLeft,killLineMarginTop+(i*126),null);
                // 绘制技能伤害类型
                if(StringUtils.isNotEmpty(skill.getDamageType())){
                    try {
                        // 伤害类型的图片
                        if (StringUtils.isNotEmpty(equipment.getDamageType())) {
                            String damage_path = "";
                            String damage_temp = RedisUtil.getString("coolq:damage:" + skill.getDamageType());
                            if (StringUtils.isNotEmpty(damage_temp)) {
                                damage_path = damage_temp;
                            } else {
                                Equipment equipment1 = new Equipment();
                                equipment1.setDamageType(skill.getDamageType());
                                damage_path = handlerDamageImage(equipment1);
                            }

                            File damageFile = new File(damage_path);
                            Image killDamageImage = ImageIO.read(damageFile);
                            g.drawImage(killDamageImage,skillDamageTypeMarginLeft,skillDamageTypeMarginTop+(i*126),30,30,null);
                        }
                    }catch (Exception e){
                        MyLog.log("绘制技能伤害类型失败"+skill.getTitle());
                    }
                }

                // 绘制技能满破水晶
                if(StringUtils.isNotEmpty(type)&&type.equals("full")){
                    // 绘制星级
                    for (int y = 0; y < 10; y++) {
                        g.drawImage(broken,brokenMarginLeft+(y*15),brokenMarginTop+(i*130),null);
                    }
                }

                // 绘制技能说明
                String maxLvDesc = skill.getMaxLvDesc()+"";
                maxLvDesc = getMaxDesc(type,maxLvDesc);

                g.setColor(KILL_CONTENT_COLOR);
                g.setFont(KILL_CONTENT_FONT);

                int j = 0,size=24;
                String temp = "";
                boolean flag = true;

                while(flag){
                    int start = j*size;
                    int end = start+size;
                    if(end>maxLvDesc.length()){
                        end = maxLvDesc.length();
                        flag = false;
                    }
                    temp = maxLvDesc.substring(start,end);
                    if(flag&&temp.getBytes().length<60){

                    }
                    // 绘制技能描述
                    g.drawString(temp,skillFirstMarginLeft,skillFirstDescMarginTop+(i*130)+20*j);
                    j++;
                }
            }
        // 使魔的技能
        }else if(equipment.getType() == 4){
            for (int i = 0; i < equipment.getDemonSkills().size(); i++) {
                DemonSkill demonSkill = equipment.getDemonSkills().get(i);
                g.setColor(KILL_NAME_COLOR);
                g.setFont(KILL_NAME_FONT);
                g.drawString(demonSkill.getTitle()+"-" + demonSkill.getType(),skillFirstMarginLeft,skillFirstMarginTop+(i*130));

                String maxLvDesc = demonSkill.getMaxLvDesc();
                maxLvDesc = maxLvDesc.trim().replaceAll(" ","");
                maxLvDesc = getMaxDesc(type,maxLvDesc);

                g.setColor(KILL_CONTENT_COLOR);
                g.setFont(KILL_CONTENT_FONT);
                int j = 0,size=20;
                String temp = "";
                boolean flag = true;
                while(flag){
                    int start = j*size;
                    int end = start+size;
                    if(end>maxLvDesc.length()){
                        end = maxLvDesc.length();
                        flag = false;
                    }
                    temp = maxLvDesc.substring(start,end);
                    /* --------对要显示的文字进行处理-------------- */
                    /*AttributedString ats = new AttributedString(temp);
                    Font fontx = new Font(font1,Font.BOLD,18);
                    ats.addAttribute(TextAttribute.FONT, fontx, 0, temp.length());
                    AttributedCharacterIterator iter = ats.getIterator();*/

                    g.drawString(temp,skillFirstMarginLeft,skillFirstDescMarginTop+(i*130)+20*j);
                    j++;
                }
            }
        }


        g.dispose();
        boolean val = false;
        try {
            val = ImageIO.write(bi, picType, file);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return val;
    }

    public static String getMaxDesc(String type,String maxLvDesc){
        if(StringUtils.isNotEmpty(type)&&type.equals("full")){
            maxLvDesc = maxLvDesc.trim().replaceAll(" ","");
            try{
                maxLvDesc = StringUtils.getFullDesc(maxLvDesc);
            }catch (Exception e){
                MyLog.log("绘制满破技能失败:"+e.getMessage());
            }
        }else{
            maxLvDesc = maxLvDesc.trim().replaceAll(" ","");
            maxLvDesc = StringUtils.replaceAllBrackets(maxLvDesc);
        }
        return maxLvDesc;
    }
}
